local skill = fk.CreateSkill {
  name = "#ling__armillary_sphere_skill",
  attached_equip = "ling__armillary_sphere",
}

Fk:loadTranslationTable{
  ["#ling__armillary_sphere_skill"] = "浑天仪",
  ["#ling__armillary_sphere-invoke"] = "浑天仪：你可以重铸你区域内的一张牌",
}

skill:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and player.phase == Player.Judge and
      not player:isAllNude()
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local cards = room:askToCards(player, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = skill.name,
      prompt = "#ling__armillary_sphere-invoke",
      cancelable = true,
      expand_pile = player:getCardIds("j"),
    })
    if #cards > 0 then
      event:setCostData(self, {cards = cards})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:recastCard(event:getCostData(self).cards, player, skill.name)
  end,
})

return skill
